import React from 'react';
import Indexs from '../indexs';
import data from '../A04';
import './basic.less';

export default () => {
  /**
   * 二级类目数据格式化
   * @param data
   */
  const transferCyclopediaSecondList = (data: any) => {
    const arr: any = [];
    data?.forEach((item: any) => {
      const index = arr.findIndex((el: any) => el.label === item.firstLetter);
      if (index === -1) {
        arr.push({ label: item.firstLetter, content: [item] });
      } else {
        arr[index]?.content?.push(item);
      }
    });
    return arr;
  };
  const list = transferCyclopediaSecondList(data.data);

  return (
    <div className="indexs-wrap">
      <Indexs list={list} onclick={() => {}} containerHeight="800px" />
    </div>
  );
};
